export default class XlsxReadError extends Error {
    constructor(errMsg: string, file: string, col: number = -1, row: number = -1) {
        let rc = (col > -1 && row > -1) ? `(${col2letter(col)},${row + 1})` : ""
        super(`<${file}>${rc} ${errMsg}`);
        this.name = '[xlsx读取错误]';
    }
}

/** 列下标转换列字母 */
function col2letter(col: number) {
    var ordA = 'A'.charCodeAt(0);
    var ordZ = 'Z'.charCodeAt(0);
    var len = ordZ - ordA + 1;
    var latter = "";
    while (col >= 0) {
        latter = String.fromCharCode(col % len + ordA) + latter;
        col = Math.floor(col / len) - 1;
    }
    return latter;
}